/*
 * @Author: 陈妮娜 969682281@qq.com
 * @Date: 2024-01-31 17:55:05
 * @LastEditors: 贺楠 1071780426@qq.com
 * @LastEditTime: 2024-10-24 15:54:10
 * @FilePath: \zdgy\yjszsy\src\components\testDetectionManage\filingEquipmentInfo\index.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import formJs from "./regexDetail.js"; //新增弹框配置项
// import publicForm from "@/components/public/up-form.vue"; //弹框form---带照片
import publicForm from "@/components/public/el-form.vue"; //弹框form
import FormLyout from '@/components/commonPublic/fromLayout.vue'
import actions from "@/actions";


import {
    getLabEquipDetail, //详情
} from "@/api/request.js";
export default {

    data() {
        return {
            isSave: true,//保存按钮是否显示
            primaryInfo: null,//上个页面跳转携带内容
            loading: false,
            formObj: formJs.formObj,
            formData: formJs.formData,
           

        };
    },
    components: {
        publicForm,
        FormLyout,
    },
    destroyed() {
        window.sessionStorage.removeItem("GxSampleManage_filingTestPersonnelInfo");
    },
    mounted() {
        this.primaryInfo = JSON.parse(sessionStorage.getItem("GxSampleManage_filingTestPersonnelInfo"))
        actions.onGlobalStateChange((state, prev) => {
            var data = prev.currentUser.projects;
            this.userInfo = prev.currentUser;
        }, true);

        if (this.primaryInfo.status == 1) { //编辑
            this.isSave = true;
            this.getDetail({
                fId: this.primaryInfo.data.fId
            })
            this.formObj.map((item) => {
                item.disabled = false;
            });

        } else if (this.primaryInfo.status == 7) { //查看
            this.isSave = false;
            this.getDetail({
                fId: this.primaryInfo.data.fId
            })
            this.formObj.map((item) => {
                item.disabled = true;
            });
        }

    },
    methods: {
        closeDialog() {
            this.$emit("close");
        },
      
        edit() {
            this.formData = this.$options.data.call(this).formData;
        },
        // 详情
        getDetail(obj) {
            this.loading = true;
            getLabEquipDetail(obj).then((res) => {
                if (res.errcode == 0) {
                    this.loading = false;
                    this.formData = res.data.equipment;
                } else {
                    this.loading = false;
                   
                    this.$message.error({
                        content: "详情接口报错：" + res.msg,
                        duration: 1000
                    });
                }

            }).catch((error) => {
                console.log("详情接口报错：" + error.msg);
                this.loading = false;
            });
        },
    },
};